<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('user/index')}">{:lang('ADMIN_USER_INDEX')}</a></li>
			<li><a href="{:url('user/add')}">{:lang('ADMIN_USER_ADD')}</a></li>
			<li class="active"><a>编辑管理员</a></li>
		</ul>
		<!--js-ajax-form-->
		<form method="post" class="form-horizontal  margin-top-20" action="{:url('User/editPost')}">
			<div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>登录名</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-user_login" name="user_login" value="{$user_login}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_nickname" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('USERNAME')}</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-user_nickname" name="user_nickname" value="{$user_nickname}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_pass" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('PASSWORD')}</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-user_pass" name="user_pass" value="" placeholder="******">
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_mobile" class="col-sm-2 control-label"><span class="form-required">*</span>手机号</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-user_mobile" name="mobile" value="{$mobile}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-parent_id" class="col-sm-2 control-label"><span class="form-required">*</span>部门名称</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="parent_id" id="input-depart_id" 
					 onchange="searchStation()">
						<option value="0">作为一级菜单</option>{$select_category}
					</select>
				</div>
			</div>

			<div class="form-group">
				<label for="input-user_email" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('ROLE')}</label>
				<div class="col-md-6 col-sm-10">
					<foreach name="roles" item="vo">
						<label class="checkbox-inline">
							<php>$role_id_checked=in_array($vo['id'],$role_ids)?"checked":"";</php>
							<input value="{$vo.id}" type="checkbox" name="role_id[]" {$role_id_checked} <if condition="cmf_get_current_admin_id() neq 1 && $vo['id'] eq 1">disabled="true"</if>>{$vo.name}
						</label>
					</foreach>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$id}" />
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
		/*组织机构下拉框选择事件*/
		function searchStation() {
	      //获取组织机构select 对象
	       var selectDepartment = document.getElementById('input-depart_id');  
	       //拿到选中项的索引：
	       var index=selectDepartment.selectedIndex;
	       //拿到选中项options的value：
	       var departmentValue = selectDepartment.options[index].value;
	       
	       //拿到选中项options的text：
	       //var departmentStr = (selectDepartment.options[index].text);
	       var departmentText = selectDepartment.options[index].text;
		   
	       $.ajax({
	            url:"/admin/user/ajaxStation",
	            //url:"/index.php/admin/user/ajaxStation",
	            data:{stationStr:departmentValue},
	            type:"get",
	            dataType:"json",
	            success: function(data){
	                $("#select_station").find("option").remove();
	                // $("#select_station").append("<option value=''>请选择</option>");
	                //动态给select 赋值
	                for(var i=0;i<data.length;i++){
	                   $("#select_station").append("<option id = '"+ data[i]["stationID"]+"' value='"+ data[i]["stationID"]+"'>"+ data[i]["stationName"]+"</option>");
	                } 
	            }
	        });
	    }
	</script>
</body>
</html>